package com.example.demo.mapper;

import com.example.demo.model.entity.Coupon;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface CouponMapper {

    @Insert("insert into coupon(name, total_price, dec_price) values(#{name}, #{totalPrice}, #{decPrice})")
    void insert(Coupon coupon);


    @Update("update coupon set name = #{name}, total_price = #{totalPrice}, dec_price = #{decPrice} where id = #{id}")
    void update(Coupon coupon);

    @Select("select * from coupon where id = #{id}")
    Coupon selectById(Integer id);

    @Delete("delete from coupon where id = #{id}")
    void delete(Integer id);

    @Select("select * from coupon limit #{offset}, #{limit}")
    List<Coupon> pageQuery(int limit, Integer offset);

    @Select("select count(*) from coupon")
    Long getCount();
}
